#ifndef __WXI_TASKHANDLER_H__
#define __WXI_TASKHANDLER_H__

#include "defs.h"
#include "threadpool.h"
#include "rtcontrol.h"

class wxiTaskHandler;

typedef void (wxiTaskHandler::*wxiTaskFunction)(void);

#define WXITASKFUNCTION(func) (wxiTaskFunction)(&func)

class wxiTaskProxy : public wxiTask
{
public:
	wxiTaskProxy(wxiTaskFunction func, wxiTaskHandler* handler, bool shoulddelete = true, bool islong = false)
		: m_func(func)
		, m_handler(handler)
		, m_shouldDelete(shoulddelete)
		, m_isLong(islong)
	{
	}

	void Execute();

	bool ShouldDelete()
	{ 
		return m_shouldDelete;
	}

	bool IsLongTask()
	{
		return m_isLong;
	}

private:
	wxiTaskFunction m_func;
	wxiTaskHandler* m_handler;
	bool m_shouldDelete;
	bool m_isLong;
};

class wxiTaskHandler
{
public:
	wxiTaskHandler() {
	}

	virtual ~wxiTaskHandler(){
	}

	void AddTask(wxiTask* task);

	void AddTask(wxiTaskFunction func, bool islong);
};

#endif